package com.appspot.chooserepository.server;

import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.appspot.chooserepository.shared.RepositoryUser;
import com.google.appengine.api.datastore.Key;

@PersistenceCapable
public class RepositoryUserData {
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key key;
	
	@Persistent
	private String user;
	
	@Persistent
	private String repository;
	
	@Persistent
	private Date lastUpdated;

	public RepositoryUserData(String user, String repository, Date lastUpdated) {
		this.user = user;
		this.repository = repository;
		this.lastUpdated = lastUpdated;
	}
	
	public RepositoryUserData(RepositoryUser repositoryUser) {
		this(repositoryUser.getUser(), repositoryUser.getRepository(), repositoryUser.getLastUpdated());
	}

	public Key getKey() {
		return key;
	}

	public String getUser() {
		return user;
	}

	public void setUser(String user) {
		this.user = user;
	}

	public String getRepository() {
		return repository;
	}

	public void setRepository(String repository) {
		this.repository = repository;
	}

	public Date getLastUpdated() {
		return lastUpdated;
	}

	public void setLastUpdated(Date lastUpdated) {
		this.lastUpdated = lastUpdated;
	}
	
	public RepositoryUser getRepositoryUser() {
		return new RepositoryUser(user,repository,lastUpdated);
	}
}
